<template>
  <div class="alipay">
    <loading v-if="loading"></loading>
    <div class="form" v-html="content"></div>
  </div>
</template>

<script>
  import { Pay } from './../../util/request.js'
  import Loading from './../../components/Loading.vue'
  export default {
    name: 'alipay',
    data() {
      return {
        orderId: this.$route.query.orderId,
        content: '',
        loading: true
      }
    },
    components: {
      Loading
    },
    mounted() {
      this.paySubmit()
    },
    methods: {
      paySubmit() {
        Pay({
          orderId: this.orderId,
          orderName: '大米商城',//扫码支付时订单名称
          amount: '0.01', //单位元
          payType: 1 //1支付宝，2微信
        }).then(res => {
          this.content = res.content
          setTimeout(() => {
            document.forms[0].submit()
          }, 100)
        })
      }
    }
  }
</script>

<style lang='scss'>

</style>